<?php
$filelogo = "http://istnu.edu.vn/home";//ROOT_PATH
	function checkbrower()
		{
				$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); 
				  if (ereg("msie 6.0", $userAgent)) { 
					return true; 
				  } else { 
					return false; 
				  } 						
		}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title><?php echo ($lang==0)?"Khoa Quốc Tế - Đại học thái nguyên":"International School - Thai Nguyen University";?></title>
		<link rel="stylesheet" type="text/css" href="css/<?php echo (checkbrower())?"style1.css":"style.css";?>"/>
		<link rel="stylesheet" type="text/css" href="css/nivo-slider.css"/>
		<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
		<script type="text/javascript" src="js/jquery.nivo.slider.js"></script>
        <script type="text/javascript" src="highslide/highslide.js"></script>
        <link rel="stylesheet" type="text/css" href="highslide/highslide.css" />
<script type="text/javascript">
    hs.graphicsDir = "/highslide/graphics/";
    hs.outlineType = null;
    hs.wrapperClassName = 'colored-border';
</script>		
		<script type="text/javascript">
			$(document).ready(function(){
				var tabActived = $("#tabbed-menu .tabs li.actived");	
				var tabActivedClasses = tabActived.attr("class");
				var ulTabbeds = $("#tabbed-menu .content ul");

				for(var i = 0; i< ulTabbeds.length; i++){
				
					var ulClass = ulTabbeds.eq(i).attr("class");
					if(tabActivedClasses.indexOf(ulClass) != -1){
						ulTabbeds.eq(i).css("display","block");
						break;
					}
				}
				
				$("#tabbed-menu .tabs li").click(function(){
						
							if($(this).attr("class").indexOf("actived") == -1){
								$("#tabbed-menu .tabs li.actived").removeClass("actived");
								$(this).addClass("actived");
								$("#tabbed-menu .content ul").fadeOut(0);
								for(var i = 0; i< ulTabbeds.length; i++){
									var ulClass = ulTabbeds.eq(i).attr("class");
									if($(this).attr("class").indexOf(ulClass) != -1){
										ulTabbeds.eq(i).fadeIn(0);
										break;
									}
								}
							}
				}); 
				$('#slider').nivoSlider();
				$("#langvi").click(function(){

					$.post(
							"<?php echo ROOT_PATH;?>/lang.php",
							{lang:0},
							function(data){
  								//alert(data);
								window.location.reload();
						 	});
				});

				$("#langen").click(function(){
					$.post("<?php echo ROOT_PATH;?>/lang.php",{lang:1},function(data)
							{
  								//alert(data);
								window.location.reload();
						 	});
			
				});

				//script chạy menu
				$("#h-menu li").hover(function(){
					$(this).children("ul").fadeIn(400);
				},function(){
					$(this).children("ul").fadeOut(400);
				});
			});
			
		</script>
	</head>
<body>
	<?php
	if(isset($_POST["login"]))
{
$username=$_POST["username"];
$password=$_POST["password"];
$st="select StudentID,StudentName from tblstudent where StudentCode='$username' and StudentPass=md5('$password')";
$kq=mysql_query($st);
$nr=mysql_num_rows($kq);
$row=mysql_fetch_assoc($kq);
if($nr>0)
{			
            $_SESSION["UserIDst"] = $row['StudentID'];	
			$_SESSION["User"] =$row['StudentName'];
}
}
 $st1="select * from weblink";
$kq1=mysql_query($st1);

?>
	<div id="header">
			<div id="h-top">
				<div id="logo" style="background: url(<?php echo $filelogo;?>/images/<?php echo ($lang==0)?"logo.vns.png":"logo.ens.png";?>);"> 
				<a href="<?php echo $filelogo;?>/images/<?php echo ($lang==0)?"logo.vn.png":"logo.en.png";?>" class="highslide" onclick="return hs.expand(this)">             
					<img  src="<?php echo $filelogo;?>/images/<?php echo ($lang==0)?"logo.vns.png":"logo.ens.png";?>" alt="logo" width="186" height="50" /></a>
                    
				</div>
  				<ul id="h-menu">
  					<?php
					
					// lấy menu gốc
					$sqlRootMenus =sprintf("select * from tblmenu where parent_id = 0 order by tblmenu.order");
					$rootMenusResult= mysql_query($sqlRootMenus) or die(mysql_error());
					//cấp 1
					$i = 0;
					$arrRootMenus = array();
				 	while($row = mysql_fetch_object($rootMenusResult)){
				 		// luuw lại menu gốc cho footer;
				 		$arrRootMenus[] = $row;
				 		$i++;
						echo "<li ".(($i==mysql_num_rows($rootMenusResult)) ? "class='last'" : ""). "><a href='".ROOT_PATH.(($row->url =="") ? "/m/". $row->id : $row->url)."'>".(($lang == 0) ? $row->vi_name : $row->en_name)."</a>";
						$sqlChildMenus1 =sprintf("select * from tblmenu where parent_id = %s order by tblmenu.order", $row->id);
						$childMenusResult1= mysql_query($sqlChildMenus1) or die(mysql_error());
						if(mysql_num_rows($childMenusResult1) >0){
							echo "<ul>";
							//cấp 2
							while($row1 = mysql_fetch_object($childMenusResult1)){
								echo "<li><a href='".ROOT_PATH. (($row1->url =="") ? "/m/". $row1->id : $row1->url)."'>".(($lang == 0) ? $row1->vi_name : $row1->en_name)."</a>";
								$sqlChildMenus2 =sprintf("select * from tblmenu where parent_id = %s order by tblmenu.order", $row1->id);
								$childMenusResult2= mysql_query($sqlChildMenus2) or die(mysql_error());
								if(mysql_num_rows($childMenusResult2) >0){
									echo "<ul>";
									//cấp 3
									while($row2 = mysql_fetch_object($childMenusResult2)){
										echo "<li><a href='".ROOT_PATH.(($row2->url =="") ? "/m/". $row2->id : $row2->url)."'>".(($lang == 0) ? $row2->vi_name : $row2->en_name)."</a></li>";
									}
									echo "</ul>";
								}
								echo "</li>";
							}
							echo "</ul>";
						}
						echo "</li>";
					}
				?>
				</ul>
				<div id="boxlanguage">
				<?php
					if($lang ==0){
					?>
					<a href="#" id="langen">
							<img src="<?php echo ROOT_PATH?>/images/en.png" alt="English" width="25" height="17"/>
						</a>
					<?php	
					}
					else
					{
					?>
						<a href="#" id="langvi">
							<img src="<?php echo ROOT_PATH?>/images/vi.png" alt="Vietnamese" width="25" height="17"/>
						</a>
					<?php
					}
				?>
				</div>
			</div><!-- end of sub.htmlh-top -->
			
			<div id="slider">
				<?php
					$sqlImages = "select link from tblhome_image";
					$rsImages = mysql_query($sqlImages) or die(mysql_error());
					while($image = mysql_fetch_object($rsImages)){
						echo "<img src='".$image->link."' alt=''/>"; 
					} 
				?>
			</div><!-- end of sub.htmlslide -->
			
			
		</div><!-- end of slide -->
	
	<div id="all">
		
		<div id="main">
			<div id="m-left">
			</div>
			<div id="m-mid">
				<div id="news" class="box">
					<div class="b-title"><?php echo ($lang==0)?"Tin tức":"News";?></div>
					<div class="b-container">
						<ul>
							<?php
							//lấy các tin tức nổi bật
							if($lang == 0){
								$sqlFeaturedArticle = "Select id, vi_title as title, vi_summary as summary, created_date From tblarticle where featured = 1 AND published = 1 ORDER BY created_date DESC LIMIT 5";
							}else{
								$sqlFeaturedArticle = "Select id, en_title as title, en_summary as summary, created_date From tblarticle where featured = 1 AND published = 1 ORDER BY created_date DESC LIMIT 5";
							}
							$rsFeaturedArticle = mysql_query($sqlFeaturedArticle) or die(mysql_error());
							while ($featuredArticle = mysql_fetch_object($rsFeaturedArticle)){
							?>
							<li>
								<a href="<?php echo ROOT_PATH;?>/view/<?php echo $featuredArticle->id;?>"><?php echo $featuredArticle->title;?> <img src="/home/images/newnew.gif" width="28" height="16" /> </a>
								<p class="summary">
									<?php echo $featuredArticle->summary."...";?>
								</p>
								<p class="readmore">
									<a href="<?php echo ROOT_PATH;?>/view/<?php echo $featuredArticle->id;?>"><?php echo ($lang==0)?"Xem tiếp":"Read more";?></a>
								</p>
							</li>
							<?php }?>
							
							
						</ul>
					</div>
				</div><!-- end of sub.htmlnews -->
				<?php
					//lấy dữ liệu đổ vào tab
					if($lang ==0){
						$sqlMenu2Tabbed = "Select id,vn_name as name from tblsection where tab > 0 ORDER BY tab DESC LIMIT 3";
					}else{
						$sqlMenu2Tabbed = "Select id,en_name as name from tblsection where tab > 0 ORDER BY tab DESC LIMIT 3";
					}
					$rsMenu2Tabbed = mysql_query($sqlMenu2Tabbed) or die(mysql_error());
				
					 
				?>
			<div id="tabbed-menu">
					<div class="tabs">
						<ul>
							<?php
							$i=0;
							$arrTabbedMenus = array(); 
							while($tabbedMenu = mysql_fetch_object($rsMenu2Tabbed)){
								$arrTabbedMenus[] = $tabbedMenu;
								echo "<li class='tab".$tabbedMenu->id.(($i==0)?" actived":"")."'>".$tabbedMenu->name."</li>";
								$i++;
							}
							?>
						</ul>
					</div>
					<div class="content box">
					<?php
					foreach($arrTabbedMenus as $tabbedMenu){
						if($lang ==0){
							$sqlTabConent = "Select id,vn_name as name from tblsection where id =".$tabbedMenu->id." LIMIT 5";
						}else{
							$sqlTabConent = "Select id,en_name as name from tblsection where id =".$tabbedMenu->id." LIMIT 5";
						}
						$rsTabConent = mysql_query($sqlTabConent) or die(mysql_error());
					?>
						<ul class="tab<?php echo $tabbedMenu->id;?>">
					<?php 
						while($tabContent = mysql_fetch_object($rsTabConent)){						
                            $article_id = $tabContent->id;					
                        if($lang ==0){
									$sqlArticle = "Select id,vi_title as title, vi_summary as summary from tblarticle where section_id =".$article_id." AND published = 1 ORDER BY art_order DESC LIMIT 5";
								}else{
									$sqlArticle = "Select id,en_title as title, en_summary as summary from tblarticle where section_id =".$article_id." AND published = 1 ORDER BY art_order DESC LIMIT 5";
								}
								
                                $rsTabConent2 = mysql_query($sqlArticle) or die(mysql_error());
                               // $article = mysql_fetch_object($rsTabConent2);       //	echo $sqlArticle; 
								//echo $article->title;
                                while($article =  mysql_fetch_object($rsTabConent2)){
							
                         ?>
							<li>	
								<a href="<?php echo ROOT_PATH."/view/".$article->id;?>"><?php echo $article->title;?><img src="/home/images/newnew.gif" width="28" height="16" /></a>
								<p class="summary">
									<?php echo $article->summary?>
								</p>
								<p class="readmore">
									<a href="<?php echo ROOT_PATH."/view/".$article->id;?>"><?php echo ($lang==0)?"Xem tiếp":"Read more";?></a>
								</p>
							</li>
					<?php       
						}
						}
					?>
						</ul>
					<?php
					}
					?>
						
							
							
					</div>
				</div>
		</div>
			<div id="m-right">
				
			</div>
			<div class="clear-fix"></div>
			
		</div>
		
		
		<?php include "footer.php";?><?php //include "callme.php";?>
		<?php include "loginlinkid.php";?>	
	</div>	
</body>
</html>
<?php 
exit;
?>
